Tooling
Mappings to 1D
- class qtealeaves.tooling.HilbertCurveMap(dim, size)[source]
The map reads the input file and is organized as an ordered dictionary. The tuple of the coordinates returns the index in the 1d chain.
Arguments
The class creator takes the following arguments
- diminteger
system dimensionality (1d, 2d, or 3d)
- sizeint, list
Dimensionality in each spatial direction [Lx, Ly, Lz]. If only an integer is given, square or cube is assumed.
Attributes
The class attributes are now all in python indices, i.e., the dictionary keys and the index in the 1d system.
- backmapping_matrix_observable(mat)[source]
We assume an n-dimensional system, e.g., n=2 for a 2d system. Takes a matrix with the index of the “flattened” over the rows and columns as input and transforms it into a 2n-dimensional tensor representing the original indices of the system.
Arguments
- matnp.ndarray with rank 2.
Result to be mapped from the indices of a TTN into their original indices.
Returns
- resultnp.ndarray with dimension 2n
The first n indices refer to the rows of the original data. The second n indices refer to the columns of the original data.
- backmapping_vector_observable(vec)[source]
We assume an n-dimensional system, e.g., n=2 for a 2d system. Takes a vector with the index of the “flattened” as input and transforms it into a n-dimensional tensor representing the original indices of the system.
Arguments
- vecnp.ndarray with rank 1
Result to be mapped from the indices of a TTN into their original indices.
Returns
- resultnp.ndarray with dimension n
The first indices contain the indices of the original n-dimensional system.
- calculate_size()[source]
The system is defined as an n-dimensional system, i.e., 1d, 2d or 3d. We return a tuple of length n with the system size along each dimension, which we determine from the keys. For example, for a rectangle of 8 by 4 sites, the tuple (8, 4) is returned as the lattice size.
- init_1d(size)[source]
Init the Hilbert curve for a 1d system. Raises an exception. ZigZag is the only one providing a mapping for 1d.
Arguments
- sizeint or list of two ints
Defines the shape of the square or rectangle.
- class qtealeaves.tooling.SnakeMap(dim, size)[source]
The map follows a snake-like mapping in 2d and generalizes it for 3d.
- class qtealeaves.tooling.ZigZagMap(dim, size)[source]
The map constructs a zig-zag mapping equal to the order of computer memory. The map loops over the smallest dimension on the innermost loop.
- init_1d(size)[source]
Trivial zig-zag mapping for a 1-dimensional system.
Arguments
- sizeint, list of one int
The size of chain.
- class qtealeaves.tooling.map_selector(dim, size, map_type)[source]
Arguments
- diminteger
system dimensionality
- sizeint, list
Dimensionality in each spatial direction [Lx, Ly, Lz]. If only an integer is given, square or cube is assumed.
- map_typestr
Selecting the map, either
HilbertCurveMap
,SnakeMap
, orZigZagMap
, or an instance ofHilbertCurveMap
.
Lattice layout
- class qtealeaves.tooling.LatticeLayout(num_x, num_y, layout_str='square')[source]
The LatticeLayout class stores the positions of the (num_x)x(num_y) grid which allows for non-square 2D lattices.
Arguments
- num_xint
Number of points in x-direction.
- num_yint
Number of points in y-direction
- layout_strstr
Either
square
ortriangle
. Default tosquare
- all_distances()[source]
Iterate over all sites to find the all the distances for each i,j point in the given lattice.
- distance(site_a, site_b)[source]
Calculate the distance between two points.
Arguments
- site_atuple of two ints or floats
Coordinates of the first site, either in the grid if integers, or in real-space coordinates if floats are passed.
- site_btuple of two ints or floats
Coordinates of the second site.
Parametrizing objects
- class qtealeaves.tooling._ParameterizedClass[source]
Abstract base class for any other class which needs to evaluate parameterization.
- eval_numeric_param(elem, params)[source]
Evaluate a numeric parameter which might be defined via the parameter dictionary.
Arguments
- elemcallable, string, or int/float
Defines the parameter either via a function which return the value, a string being an entry in the parameter dictionary, or directly as the numeric value.
- paramsdict
The parameter dictionary, which will be passed to callables and used to evaluate string parameters.
- static eval_str_param(elem, params)[source]
Evaluate a string parameter.
Arguments
- elemcallable, string, or int/float
Defines the parameter either via a function which return the value, or directly as the numeric value.
- paramsdict
The parameter dictionary, which will be passed to callables.
- static eval_str_param_default(elem, params, default)[source]
Evaluate a string parameter and allow to set default. It sets the default as soon as elem is not callable.
Arguments
- elemcallable, …
Defines the parameter via a callable. Any other variable will be overwritten by the default.
- paramsdict
The parameter dictionary passed to the callable.
- defaultstr
The default value if elem is not callable.
Restricted classes
Fortran interfaces
- class qtealeaves.tooling.write_nml(namelist_name, namelist_dict, namelist_file)[source]
Write Fortran namelist from an ordered dictionary.
Parameters
- class qtealeaves.tooling.write_tensor(tensor, dest, cmplx=True, **kwargs)[source]
Write a tensor stored in a numpy matrix to a file. Conversion to column major is taken care of here.
Arguments
- tensornp.ndarray
Tensor to be written to the file.
- deststr, or filehandle
If string, file will be created or overwritten. If filehandle, then data will be written there.
- class qtealeaves.tooling.write_symtensor(tensor, dest, generators, gen_type, add_links=None, cmplx=True, **kwargs)[source]
Write a tensor stored in a numpy matrix to a file.
Arguments
tensor : np.ndarray of rank 2
dest : str, or filehandle
generators : list of np.ndarray of rank 2
gen_type : str
add_links : TBA
cmplx : bool, optional
Details
There are multiple options to write a AbelianSymTensor. We list one after another.
Coupling sectors
- [AbelianSymCombinedGroup]
number of symmetries, int [AbelianSymGroup], dimension(#sym)
type_id, char [if U1]
[nothing]
- [if Zn]
order, int
[back to the AbelianSymTensor] number of links : int are links outgoing : logical(number_of_links) [AbelianSymLink] in for loop
[skip symnmetry] [irrepListing]
[skip format] [else case (optimized, format=L)] [if do_read_sym_indices_ = false]
number of symmetry indices, int assume_sym_indices_full , logical [if not full] sym_indices_, integer(#sym_indices)
- number_of_sectors, int –> irreps(#sym_ind, #sectors), total number
of sectors even if here not active
irreps, integer(:, :) [if do_read_has_deg_ = false] logical [if do_read_deg_ = true] degeneracies, integer(#sectors)
format, char(3) (‘s’ for coupling sectors in the example) number_elements, int [sectors] in for loop
coupling_sectors, int(#links); deg_indices, int(#links); value, DTYPE
Coupling irreps
[AbelianSymCombinedGroup] … [AbelianSymTensor] number of links : int are links outgoing : logical(number_of_links) [AbelianSymLink] in for loop … format, char(3) (‘S’ for coupling irreps in the example) number_elements, int [sectors] in for loop
coupling_irreps, int(#sym, #links); deg_indices, int(#links); value, DTYPE
Examples
1 = number of symmetries U = U(1) symmetry 2 = number of links T F = are_links_outgoing 2 = number of sectors? 0 = irreps(:, 1) 1 = irreps(:, 2) 126 141 = degeneracies ? 2 0 1 126 141 S = format irreps 131 = number of elements specified as irreps 0 0, 1 8, (-1.0, 0.0) : 0, 0 = coupling_irreps, 1,8 = deg_indices, (…) = value …
1 = number of symmetries U = U(1) symmetry 3 = number of links T F F = are_links_outgoing [1st link]
2 number of sectors 0 irreps(:, 1) 1 irreps(:, 2) 126 141
- [2nd link]
2 0 1 126 141
- [3rd link]
1 number of sectors 1 irreps(:, 1) 1 degeneracies
S = format, file provides irreps 96 = number of elements specified as irreps 1 0 1, 1 1 1, (1.0, 0.0) 1 0 1, 2 2 1, (-1.0, 0.0) …
- class qtealeaves.tooling.read_tensor(file, cmplx=True, order='F')[source]
Read a tensor written in a file from fortran and store it in a numpy matrix. Conversion to row major is taken care of here if order=’F’. author: mb
Parameters
- file: str, or filehandle
If string, file will be opened. If filehandle, then data will be read from there.
- cmplx: bool, optional
If True the tensor is complex. Otherwise is real. Default to True.
- order: str, optional
If ‘F’ the tensor is transformed from column-major to row-major, if ‘C’ it is left as read.